package com.wpre.seleniumtest.PageTest;

import com.wpre.seleniumtest.utils.DriverUtil;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2025-03-28
 * Time: 11:42
 */
public class Login {
    public static void login(WebDriver driver) throws InterruptedException {
        WebElement userNameElement = driver.findElement(By.xpath("//*[@id=\"phoneNumber\"]"));
        userNameElement.click();
        userNameElement.sendKeys("13576674935");

        WebElement PasswordElement = driver.findElement(By.xpath("//*[@id=\"password\"]"));
        PasswordElement.click();
        PasswordElement.sendKeys("12345678");

        WebElement button = driver.findElement(By.xpath("//*[@id=\"loginForm\"]/button"));
        button.click();
    }

    //文件上传
    void test() {
        WebDriver driver = DriverUtil.createDriver("http://8.138.194.44:8080/blogin.html");
        File uploadFile = new File("C:\\Users\\LianBao\\Desktop\\images\\kj.jpg");
        WebElement fileInput = driver.findElement(By.cssSelector("input[type=file]"));
        fileInput.sendKeys(uploadFile.getAbsolutePath());
    }
}
